#ifndef _MAIN_SERVICE_H_
#define _MAIN_SERVICE_H_

#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std ;

#include "repoll.h"
#include "rtask.h"


const short gsh_listen_port = 4999; //gzxx
const int gi_listen_size = 128;

class main_service
{		
	private:
		main_service() ;
		~main_service( ) ;
		
		main_service(const main_service&);
		main_service& operator=(const main_service&);

		void init_task(const int i_socket ) ;
		void clear_task(const int i_socket);

		static void* epoll_accept_routine(void* arg) ;
		void epoll_accept_entry(void);

		static void* epoll_wait_routine(void* arg) ;
		void epoll_wait_entry(void);

		repoll mservice_epoll ;
		
		map<int, rtask*> mm_task ;

	public:
		static main_service& _instance()
		{
			static main_service instance ;
			return instance ;
		}
		
		bool start(void) ;

		void delete_task(rtask& r_task) ;
} ;

#endif

